package com.asdc.demo.works;

import com.asdc.demo.utils.RabbitMqUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

/**
 * @ClassName Task01
 * @Author bsy
 * @Description 启动生产者任务
 * @Date 2022/3/12 16:18
 * @Version 1.0
 */
public class Task01 {
    private static final String QUEUE_NAME = "QUEUE_VVYX";

    public static void main(String[] args) throws Exception {
        try (Channel channel = RabbitMqUtils.getChannel()) {
            channel.queueDeclare(QUEUE_NAME, false, false, false, null);
            Scanner scanner = new Scanner(System.in);
            while (scanner.hasNext()){
                String msg = scanner.next();
                channel.basicPublish("",QUEUE_NAME,null,msg.getBytes());
            }
        }
    }
}
